package com.xc.hotelmgr.webapi.modules.op.controller;


import com.xc.hotelmgr.webapi.common.utils.R;
import com.xc.hotelmgr.webapi.modules.mq.service.HotelToMQService;
import com.xc.hotelmgr.webapi.modules.mq.dto.SendRsDto;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.bouncycastle.tsp.TSPUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("op/rates")
public class SendRsController {

    @Autowired
    private HotelToMQService hotelToMQService;

    @RequestMapping(value = "send", method = RequestMethod.GET)
    @RequiresPermissions("op:rates:send")
    public R send(@RequestParam Map<String, Object> params) {
        Integer storeId = null;
        Integer sendType = null;
        Long sendId = null;
        Object sendIdO = params.get("sendId");
        Object sendTypeO = params.get("sendType");
        Object storeIdO = params.get("storeId");
        if(sendIdO!=null) {
            sendId = Long.valueOf((String) sendIdO);
        }
        if(sendTypeO!=null) {
            sendType = Integer.valueOf((String) sendTypeO);
        }
        if(storeIdO!=null) {
            storeId = Integer.valueOf((String)storeIdO);
        }
        SendRsDto sendRsDto = SendRsDto.builder()
                .sendId(sendId)
                .sendType(sendType)
                .storeId(storeId)
                .build();
        hotelToMQService.sendRs(sendRsDto);
        return R.ok();
    }


}
